package com.xuecheng.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xuecheng.system.mapper.DictionaryMapper;
import com.xuecheng.system.model.po.Dictionary;
import com.xuecheng.system.service.IDictionaryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 数据字典 服务实现类
 * </p>
 *
 * @author itcast
 */
@Service
public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Dictionary> implements IDictionaryService {

    /**
     * 查询所有数据字典内容
     *
     * @return 字典列表
     */
    @Override
    public List<Dictionary> queryAll() {
        return this.list();
    }

    /**
     * 根据code查询数据字典
     *
     * @param code -- String 数据字典Code
     * @return 数据字典对象
     */
    @Override
    public Dictionary getByCode(String code) {
        return lambdaQuery()
                .eq(Dictionary::getCode, code)
                .one();
    }
}
